<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>一朵 - 我的收藏</title>

    <!-- swiper-2.7css -->

    <link rel="stylesheet" href="__STATIC__/index/js/swiper/idangerous.swiper.css">

    <!-- swiper-2.7js -->

    <script src="__STATIC__/index/js/swiper/idangerous.swiper.min.js"></script>

    <!-- jquery-3.2.1引用 -->

    <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>

    <!-- 阿里巴巴矢量图库 -->

    <link rel="stylesheet" href="http://at.alicdn.com/t/font_561814_z72ky81kih08uxr.css">

    <!-- 公共头部 脚部 -->

    <link rel="stylesheet" href="__STATIC__/index/css/global/global.css">

    <!-- 超过1200屏幕 -->

    <link rel="stylesheet" media="screen and (min-width: 1200px)" href="__STATIC__/index/css/collect/collect1200.css" />

    <!-- 1080-1200 -->

    <link rel="stylesheet" media="screen  and (min-width: 1080px) and (max-width: 1199px) " href="__STATIC__/index/css/collect/collect1080.css"
    />

    <!-- 960-1080 -->

    <link rel="stylesheet" media="screen  and (min-width: 960px) and (max-width: 1079px) " href="__STATIC__/index/css/collect/collect960.css"
    />

    <!-- 768-959 -->

    <link rel="stylesheet" media="screen  and (min-width: 768px) and (max-width: 959px) " href="__STATIC__/index/css/collect/collect768.css"
    />

    <!-- 568-767 -->

    <link rel="stylesheet" media="screen  and (min-width: 568px) and (max-width: 767px) " href="__STATIC__/index/css/collect/collect568.css"
    />

    <!-- 375-567 -->

    <link rel="stylesheet" media="screen  and (min-width: 375px) and (max-width: 567px) " href="__STATIC__/index/css/collect/collect375.css"
    />

    <!-- 小于375-->

    <link rel="stylesheet" media="screen  and (max-width: 374px) " href="__STATIC__/index/css/collect/collect320.css" />

    <!--一引入layer-->

    <script src="__STATIC__/layer/layer.js"></script>


    {include file="public/page_css" /}

</head>



<body>



    <div class="M">
        <div class="m-header">

            <div>

                <span onclick="go_back();">

                    <span class="iconfont icon-xiangzuo"></span>

                    返回

                </span>

                <span>我的收藏</span>

                <span>

                    {if condition="!empty($realname)"}

                    <a href="{:url('User/index')}" class="my">

                        {$realname}

                    </a>

                    {else /}

                    <a href="{:url('Login/loginin')}">登录</a>

                    <a href="{:url('Login/register')}">注册</a>

                    {/if}

                    <a href="{:url('MyCart/my_cart')}" class="car">

                        <span class="iconfont icon-gouwuche"></span>

                        <span>{$cart_num}</span>

                    </a>

                </span>

            </div>

        </div>
        {if condition="!empty($all_list)"}
        <div class="m-goods">

            {foreach name="list" item="v"}

            <div class="m-goods-content">

                <span>

                    <img src="{$v.logo}" alt="">

                </span>

                <span>

                    <p>

                        <span>{$v.name}</span>

                        <span>￥{$v.price}</span>

                    </p>

                </span>

                <span>

                    <span class="iconfont icon-shoucang1" onclick="cancel_collect({$v.id})"></span>

                </span>

            </div>

            {/foreach}

        </div>
        {/if}
        {if condition="empty($all_list)"}
        <div class="m-kong">
            <img src="__STATIC__/index/img/collect.png" alt="">
            <p>您的收藏列表为空</p>
            <p>······</p>
        </div>
        {/if}
    </div>

    <!------------------------ PC ------------------------>



    <div class="PC">

        <!-- 公共头部 -->

        {include file="public/p_header" /}

        <!-- 公共头部结束 -->

        <div class="pc-content">

            {include file="public/p_user" /}



            <div class="PC_right">

                {include file="public/p_user_info" /}

                <div class="pc-tihuan">

                    <div class="pc-tihuan-headline">

                        <p>收藏列表</p>

                    </div>
                    {if condition="!empty($all_list)"}
                    <!-- 循环开始 -->
                    <div class="pc-xunhuan">

                        {foreach name="list" item="v"}

                        <div>

                            <div class="pc-goods">

                                <span>

                                    <a href="{:url('GoodsList/goods_detail')}?id={$v.goods_id}">

                                        <img src="{$v.logo}" alt="">

                                    </a>

                                </span>

                                <span>

                                    <a href="{:url('GoodsList/goods_detail')}?id={$v.goods_id}">

                                        <p>{$v.name}</p>

                                    </a>

                                </span>

                                <span>

                                    <span>￥{$v.price}</span>

                                    <!--<span>x</span>-->

                                    <!--<span>1</span>-->

                                </span>

                                <span>

                                    <a href="javascript:;" class="pc-dingdan" onclick="cancel_collect({$v.id})">取消收藏</a>

                                </span>

                            </div>

                        </div>

                        {/foreach}

                    </div>
                    <!-- 循环结束 -->
                    {/if}
                    {if condition="empty($all_list)"}
                    <div class="pc-kong">
                        <img src="__STATIC__/index/img/collect.png" alt="">
                        <p>您的收藏列表为空</p>
                        <p>······</p>
                    </div>
                    {/if}
                </div>

            </div>

        </div>

        <div class="pc-Flip pages" style="text-align: center;">

            {$page}

        </div>

        <!-- 公共脚部  -->

        {include file="public/p_footer" /}

        <!-- 公共脚部 结束 -->



    </div>

    <div style="display:none;" id="cur_page">{$cur_page}</div>

    <div style="display:none" id="all_page">{$all_page}</div>

    <script>
        /**

                                 * 返回上一页

                                 */

        function go_back() {

            window.history.back(); //返回上一页

        }



        $(window).scroll(function () {

            console.log($(document).scrollTop());

            console.log($(document).height());

            console.log($(window).height());

            console.log($(document).height() - $(window).height() - 1);

            if ($(document).scrollTop() >= $(document).height() - $(window).height() - 1) {

                var cur_page = parseInt($('#cur_page').text()); //当前页码

                var all_page = parseInt($('#all_page').text()); //当前页码

                if (all_page != cur_page) {

                    $.post("{:url('User/get_ajax_collect')}",

                        {
                            cur_page: cur_page
                        },

                        function (data) {

                            if (data.code == 1) {

                                var html = '';

                                for (var i = 0; i < data.data.length; i++) {

                                    html += '<div class="m-goods-content"><span><img src="' + data.data[i][
                                            "logo"
                                        ] + '" alt=""></span><span><p><span>' + data.data[i]["name"] +
                                        '</span><span>￥' + data.data[i]["price"] +
                                        '</span></p></span><span><span class="iconfont icon-shoucang1" onclick="cancel_collect(' +
                                        data.data[i]["id"] + ')"></span></span></div>';

                                }

                                $('.m-goods').append(html);

                                $('#cur_page').text(data.msg);

                                if (cur_page + 1 == all_page) {

                                    $('.m-goods').append('<p>没有更多了</p><p>...</p>');

                                }

                            }

                        }

                    );



                }

            }

        });



        /**

         * 取消收藏

         */

        function cancel_collect(id) {

            $.post("{:url('User/cancel_collect')}",

                {
                    id: id
                },

                function (data) {

                    if (data.code == 1) {

                        layer.msg('取消成功', {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {

                            layer.close(index);

                            location.reload();

                        });

                        return false;

                    } else {

                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {

                            layer.close(index);

                        });

                        return false;

                    }

                }

            );

        }



        /**

         * 完善会员信息

         */

        function edit_member_info() {

            window.location.href = "{:url('User/my_center')}";

        }
    </script>

</body>



</html>